<template>
  <!-- 用户权限模块 -->
  <div class="permissions-container">
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item :to="{ path: '/rights' }">权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片区域 -->
    <el-card shadow="always">
      <el-table stripe style="width: 100%" :data="RightList" highlight-current-row border>
        <el-table-column type="index" label="#">
        </el-table-column>
        <el-table-column prop="authName" label="权限名称">
        </el-table-column>
        <el-table-column prop="path" label="路径">
        </el-table-column>
        <el-table-column label="权限等级">
          <template slot-scope="scope">
            <el-tag size="medium" :type="scope.row.level == 0 ? '' : 'success'">{{ scope.row.level }}级</el-tag>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      RightList: []// 用户数据
    }
  },
  created() {
    // 组件创建完的时候发起 axios 的 get请求数据
    this.getRightList()
  },
  methods: {
    async getRightList() {
      // 发起 axios 的 get请求数据用户数据
      const { data: res } = await this.$http.get('/rights/list')
      // 对数据进行校验
      if (res.meta.status !== 200) return this.$message.error('获取用户列表失败')
      this.RightList = res.data
    }
  }
}
</script>

<style lang="less" scoped>
.permissions-container {

  /* 卡片区域 */
  .el-card {
    margin-top: 20px;

    .el-tag {
      width: 100px;
      height: 30px;
      text-align: center;
    }
  }
}
</style>
